package com.landon.id.generator.segment;

import com.landon.id.generator.IdGenerator;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author shishaopeng
 * Date: 2022-10-24-21-45
 * Desc:
 */
@Service
public class SegmentIdGenerator implements IdGenerator {

    @Resource
    private BusinessCosIdSegmentCache businessCosIdSegmentCache;

    @Override
    public Long getLongCosId(String businessId) {
        // 获取业务号段链
        BusinessCosIdSegmentChain businessCosIdSegmentChain = businessCosIdSegmentCache.getBusinessCosIdGenerator(businessId);
        // 获取id
        return businessCosIdSegmentChain.getId();
    }

    @Override
    public BusinessCosIdSegmentChain getBusinessCosIdSegmentChain(String businessId) {
        return businessCosIdSegmentCache.getBusinessCosIdGenerator(businessId);
    }
}
